#include<iostream>
using namespace std;
int N;
int data[101];
int total=0;
int ave;
int cnt=0;
void div()
{
for(int i=1;i<=N;++i)
{
if(data[i]<ave)
{
int need=ave-data[i];
cnt++;
data[i+1]=data[i+1]-need;
}
if(data[i]>ave)
{
int rich=data[i]-ave;
cnt++;
data[i+1]=data[i+1]+rich;
}  
}
} 
int main()
{
cin>>N;
for(int i=1;i<=N;++i)
{
cin>>data[i];
total+=data[i];
}
ave=total/N;
div();
cout<<cnt<<endl; 
return 0;
} 
